Add phase upgrade support for Maven 4.1.0 model upgrades#11215
Merged
gnodet merged 2 commits intoapache:masterfrom Oct 8, 2025
Merged
Add phase upgrade support for Maven 4.1.0 model upgrades#11215gnodet merged 2 commits intoapache:masterfrom
gnodet merged 2 commits intoapache:masterfrom
Conversation
This commit implements automatic phase name upgrades when upgrading Maven projects from model version 4.0.0 to 4.1.0. The deprecated Maven 3 phase names are automatically converted to their Maven 4 equivalents: - pre-clean → before:clean - post-clean → after:clean - pre-integration-test → before:integration-test - post-integration-test → after:integration-test - pre-site → before:site - post-site → after:site The upgrade functionality: - Only applies when upgrading to model version 4.1.0 or higher - Processes all plugin executions in build/plugins, build/pluginManagement, and profile/build/plugins sections - Preserves non-deprecated phase names unchanged - Includes comprehensive test coverage for all scenarios This enhancement ensures that Maven projects upgrading to 4.1.0 will automatically have their deprecated phase references updated to use the new Maven 4 phase naming convention.
Replace hardcoded phase name strings with proper Maven API constants: - Use Lifecycle.BEFORE and Lifecycle.AFTER for phase prefixes - Use Lifecycle.Phase.CLEAN and Lifecycle.Phase.INTEGRATION_TEST for phase names - Use Lifecycle.SITE for site lifecycle phase This ensures consistency with Maven's lifecycle definitions and makes the code more maintainable by using the official API constants.
cstamas
approved these changes
Oct 8, 2025
Contributor
Author
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements automatic phase name upgrades when upgrading Maven projects from model version 4.0.0 to 4.1.0. The deprecated Maven 3 phase names are automatically converted to their Maven 4 equivalents.
Changes Made
Phase Mappings
The following deprecated phase names are automatically upgraded:
pre-clean→before:cleanpost-clean→after:cleanpre-integration-test→before:integration-testpost-integration-test→after:integration-testpre-site→before:sitepost-site→after:siteImplementation Details
ModelUpgradeStrategy.java: AddedupgradePhases()method that processes all plugin executionsLifecycle.BEFORE,Lifecycle.AFTER,Lifecycle.Phase.CLEAN,Lifecycle.Phase.INTEGRATION_TEST, andLifecycle.SITEfor consistencybuild/plugins,build/pluginManagement, andprofile/build/pluginssectionsTesting
Usage
Users can now run:
And their POM files will be automatically upgraded with:
modulestosubprojectselementsExample Transformation
Before (Maven 4.0.0):
After (Maven 4.1.0):
Backward Compatibility
Testing
This enhancement provides a smooth migration path for Maven projects upgrading to version 4.1.0 by automatically handling the deprecated phase name conversions.
Pull Request opened by Augment Code with guidance from the PR author